﻿using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Windows.Navigation;
using System.Windows.Threading;
using SocialApi.TestApp.Annotations;

namespace SocialApi.TestApp.ViewModels
{
    public abstract class ViewModelBase : INotifyPropertyChanged
    {
        #region Члены

        public event PropertyChangedEventHandler PropertyChanged;

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion

        /// <summary>
        /// Текущий <see cref="System.Windows.Threading.Dispatcher"/>
        /// </summary>
        protected Dispatcher Dispatcher { get; private set; }

        /// <summary>
        /// Текущий <see cref="NavigationService"/>
        /// </summary>
        protected NavigationService NavigationService { get; private set; }

        protected ViewModelBase(Dispatcher dispatcher, NavigationService navigationService)
        {
            Dispatcher = dispatcher;
            NavigationService = navigationService;
        }
    }
}